data "aws_vpc" "main" {
  filter {
    name   = "tag:Name"
    values = ["app2"]  # 使用与创建 VPC 相同的名称查找
  }
}

data "aws_subnets" "main" {
  filter {
    name   = "vpc-id"
    values = [data.aws_vpc.main.id]  # 使用查找到的 VPC ID
  }
}

data "aws_security_group" "sg" {
  filter {
    name   = "tag:Name"
    values = ["web-sg"]  # 使用与创建 VPC 相同的名称查找
  }
}

module "alb-app1" {
  source          = "../../modules/alb"
  lb_name         = "example-lb"
  tg_name         = "example-tg"
  security_groups = [data.aws_security_group.sg.id]
#  security_groups = ["sg-055ba74c3bbf67749"]
  subnets         = data.aws_subnets.main.ids
  vpc_id          = data.aws_vpc.main.id
}
